// const test =computed(()=>store.state.test.count)
// mutations
// 	store.commit('test/add', 5)
// actions
// store.dispatch('login/login')
//  使用模块化
import {takeClassList} from '@/uitls/tool.js'
export default {
	// 独立命名空间
	namespaced: true,
	state: {
		theMonthData:{},// 预算需要的 本月记录 总和 收入 支出 
		theMonthYusuanSum:{},
	},
	getters: {},
	mutations: {
		getTheMonthData(state,time){
			state.theMonthData = { //这个月份总体
				time:time,
				total: 0,
				income: 0,
				expenses: 0
			}
			let allData=this.state.mainData.allData[time]
			if(allData!=void 0 && allData?.length>0){
				allData.forEach((item)=>{
					state.theMonthData.total += parseFloat(item.addValue) * (item.showClass === 1 ? 1 : -1);
					state.theMonthData.income += item.showClass === 1 ? parseFloat(item.addValue) : 0;
					state.theMonthData.expenses += item.showClass !== 1 ? parseFloat(item.addValue) : 0;
				})
			}
		},
		getTheMonthYusuanSum(state,time){
			let sum=0
			let yusuanData=this.state.mainData.yusuanData[time]
			if(yusuanData!=void 0 && yusuanData?.length>0){
				for(let one of yusuanData){
					sum+=parseFloat(one.sum)
				}
			}
			state.theMonthYusuanSum={
				time:time,
				data:sum
			}
		}
	},
	actions: {}
};